import { createStore,applyMiddleware } from 'redux';
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import rootReducer from '@/reducers';
import promise from 'redux-promise-middleware';
import { composeWithDevTools } from 'redux-devtools-extension';
const configStore = (preload) => {
  const store =  createStore(
    rootReducer,
    preload,
    composeWithDevTools(applyMiddleware(logger,thunk,promise()))
  )
  if(process.env.NODE_ENV === 'development'){
    if(module.hot){
      module.hot.accept('@/reducers',()=>{
        store.replaceReducer(rootReducer)
      })
    }
  }
  return store;
}
export default configStore;